Socket
Socket
Sign inDemoInstall

babel-plugin-htmlbars-inline-precompile

Package Overview
Dependencies
2
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-htmlbars-inline-precompile

Babel plugin to replace tagged template strings with precompiled HTMLBars templates


Version published
Weekly downloads
247K
increased by1.48%
Maintainers
4
Install size
271 kB
Created
Weekly downloads
 

Changelog

Source

v4.4.6 (2021-03-17)

:bug: Bug Fix
  • #357 [BUGFIX] Use a unique identifier for each reference (@pzuraq)
Committers: 1

Readme

Source

babel-plugin-htmlbars-inline-precompile

Build Status

Babel plugin to replace tagged .hbs formatted strings with a precompiled version.

Requirements

  • Node 8+
  • Ember 2.10+
  • Babel 7

Usage

Can be used as either a normal function invocation or a tagged template string:

import hbs from 'htmlbars-inline-precompile';

hbs`some {{handlebarsthingy}}`;
hbs('some {{handlebarsthingy}}');

When used as a normal function invocation, you can pass additional options (e.g. to configure the resulting template's moduleName metadata):

import hbs from 'htmlbars-inline-precompile';

hbs('some {{handlebarsthingy}}', { moduleName: 'some/path/to/file.hbs' });

Babel Plugin Usage

var HTMLBarsCompiler = require('./bower_components/ember/ember-template-compiler');
var HTMLBarsInlinePrecompile = require('babel-plugin-htmlbars-inline-precompile');

require('babel').transform("code", {
  plugins: [
    [HTMLBarsInlinePrecompile, {precompile: HTMLBarsCompiler.precompile}],
  ],
});

Example

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module("my component", function(hooks) {
  setupRenderingTest(hooks);

  test('inline templates ftw', async function(assert) {
    await render(hbs`hello!`);

    assert.dom().hasText('hello!');
  });
});

results in

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module("my component", function(hooks) {
  setupRenderingTest(hooks);

  test('inline templates ftw', async function(assert) {
    await render(Ember.HTMLBars.template(function() {
      /* crazy HTMLBars template function stuff */
    }));

    assert.dom().hasText('hello!');
  });
});

FAQs

Last updated on 17 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc